<script>
function checkform(){
	commonEffection.setLoading();
	$('#addBlogForm').submit();
}
</script>
<div class="frame_pmtips" style="margin-bottom: 4px;">
	<div class="tips_body">
	修改臂章信息后可以在发布产品的时候指定特定臂章 <br />
	</div>
</div>
<div class="frame_addfactoryDiv">
  <form name="addBulletinForm" id="addBulletinForm" enctype="multipart/form-data" action="administrator<?=CHOSING_DE?>product<?=CHOSING_DE?>badgeupdate" method="post">
  <table width="100%" border="1" cellpadding="0" cellspacing="0" bordercolor="#c8d9e9">
    <tr>
      <td class="ri-bbgg">臂章信息：</td>
      <td class="le">
        <div>
        	
			  	<div>可选臂章: <input type="button" onclick="addselectbadgepatch(this);" value="添加" /></div>
			  	  <?php $i=1;?>
				  <?foreach($this->select_badgepatch as $value):?>
				  	<?php if (is_array($value)):?>
						<div><input name="select_badgepatch[]" value="<?=$value['name']?>" />
							 <?php foreach ($value['img'] as $v):?>
							 <div>
							 <input type="hidden" name="badge_img_<?php echo $i;?>[]" value="<?=$v?>">
							 <img src="<?php echo $v;?>" width="100" height="100"/><br/><input type="button" value="删除" onclick="$(this).parent().remove();"></input>
							 </div>
							 <?php endforeach;?>
						  <input type="file" name="badgepatch_img[]" /> <input type="button" onclick="uploadimg(this);" value="上传" /><input type="button" onclick="deleteselectbadgepatch(this);" value="删除" /></div>
					<?php else:?>
						<div><input name="select_badgepatch[]" value="<?=$value?>" /><input type="hidden" name="badge_img_<?php echo $i;?>[]" value="">    <input type="file" name="badgepatch_img[]" /> <input type="button" onclick="uploadimg(this);" value="上传" /><input type="button" onclick="deleteselectbadgepatch(this);" value="删除" /><br/></div>
					<?php endif;?>
					<?php $i++;?>
			      <?endforeach;?>
			      <iframe id="productIframe" width="0" height="0" name="productIframe"></iframe>
			<input type="hidden" value="<?php echo count($this->select_badgepatch);?>" name="myindex"/>
        	<input type="hidden" value="<?=$this->data['badge_id']?>" name="badge_id" id="badge_id" />
        </div>
	  </td>
    </tr>
    <tr>
      <td colspan="2" class="se" align="center">
        <input name="button2" type="submit" class="iput" value="保 存"  />　　
        <input name="button" type="button" class="iput" value="返 回" onclick="commonEffection.confirmBack();" />
      </td>
    </tr>
  </table>
</div>
<script>
	var myupload = {
		current: null,
	};
	var myindex = <?php echo count($this->select_badgepatch);?>;
    function addselectbadgepatch(thisInput){
    	myindex = myindex+1;
    	$('input[name="myindex"]').val(myindex);
		$(thisInput).parent().parent().append('<div><input name="select_badgepatch[]" />    <input type="file" name="badgepatch_img[]" /> <input type="hidden" name="badge_img[]" value=""> <input type="button" onclick="uploadimg(this);" value="上传" />   <input type="button" onclick="deleteselectbadgepatch(this);" value="删除" /></div>');
		commonEffection.resetFrame('admins_frame',true);
	}
	function deleteselectbadgepatch(thisInput){	
		$(thisInput).parent().remove();
		commonEffection.resetFrame('admins_frame',true);
	}
	function uploadimg(obj)
	{
		myupload.current = $(obj);
		var oldAction=$('#addBulletinForm').attr('action');
		var oldTarget=$('#addBulletinForm').attr('target');
		$('#addBulletinForm').attr('action','administrator-product-uploadimg1');
		$('#addBulletinForm').attr('target','productIframe');
		$('#addBulletinForm').submit();
		$('#addBulletinForm').attr('action',oldAction);
		$('#addBulletinForm').attr('target',oldTarget);
	}
	function setImg(url)
	{
		myupload.current.parent().append('<img src="'+url+'" width="100" height="100"/>');
		myupload.current.parent().append('input[name="badge_img[]"]').val(url);
		myupload.current.parent().find('input[name="badgepatch_img[]"]').remove();
		myupload.current.remove();
		commonEffection.resetFrame('admins_frame',true);
	}
</script>